import Vue from 'vue'
import Vuex from 'vuex'
import Client from './client'
import User from './user'
import TravelList from './travel-list'
import Order from './order'
import MyOrders from './my-orders'
import Community from './community'
import MyTravel from './my-travel'

import SignIn from './signIn'

Vue.use(Vuex)

/**
 * @name global-mutation
 * @param {Object} state module state
 * @param {Object} options state that need to update
 */

export function setState(state, options) {
  Object.keys(options).forEach(key => {
    if (Object.prototype.hasOwnProperty.call(state, key)) {
      state[key] = options[key]
    }
  })
}

const store = new Vuex.Store({
  modules: { Client, TravelList, Order, MyOrders, Community, SignIn, MyTravel }
})

export default store
